//
//  WmcCalendarSelectAlertView.swift
//  YPWatermarkCamera
//
//  Created by yupao_ios_macmini06 on 2022/10/20.
//

import Foundation
import YPUIKit

/// 统一弹窗风格
class WmcCalendarSelectPopView: WmcCalendarSelectView {
    class func calendarView() -> WmcCalendarSelectPopView {
        let minDate = "2020-01-01".yp.date(format: .iso8601Day, identifier: .asia(.Shanghai)) ?? Date()
        let maxDate = WmcDateManager.shared.networkDate.value?.yp.string(.iso8601Day, identifier: .europe(.London)).yp.date(format: .iso8601Day, identifier: .asia(.Shanghai)) ?? Date()
        let selectCalendarView = WmcCalendarSelectPopView(minDate: minDate, maxDate: maxDate)
        return selectCalendarView
    }
}

extension WmcCalendarSelectPopView: YPUIPresentTarget {
    func show() {
        let config = YPUIPresentController.Config()
        config.contentView = self
        config.transitionAnimated.usingSpringWithDamping = .init(appearDuration: 1, disappearDuration: 1)
        config.transitionAnimated.initialSpringVelocity = .init(appearDuration: 0, disappearDuration: 0)
        config.style = .sheet(.Create { make in
            let height = 44.wmc_autoVer + 42 + 325 + Wmc_safeAreaBottom
            make.left.right.bottom.equalToSuperview()
            make.height.equalTo(height)
        })
        present(config: config)
    }
}
